/* ------------------------------------------------------------------------*/
/* COPYRIGHT (c) 1992 CONTEMPORARY CONTROL SYSTEMS, INC.                   */
/* ------------------------------------------------------------------------*/
/* Project:       20020 DRIVER                                             */
/* Filename:      ARC20.H                                                  */
/* Description:   DEFINITIONS FOR THE ARCWARE ROUTINES                     */
/* Version:       1.00                                                     */
/* Author:        M. JUSTICE                                               */
/* History:       ORIGINAL 09/14/92                                        */
/* ------------------------------------------------------------------------*/

/* read status & write interrupt register 0 */
#define   TA          0x01    /* transmitter available */
#define   TMA         0x02    /* transmitter msg ack */
#define   RECON       0x04    /* line idle timere time out */
#define   RI          0x80    /* waiting for next enable rx to page fnn */

/* read status register 0 */
#define   TEST        0x08    /* test or diagnostic bit, 0 normally */
#define   POR         0x10    /* software or hardware reset occurred, cleared by
                                 the clear flags command */

/* read diagnostic, write command register 1 */
#define   TENT_ID     0x04    /* set if tent ID == 1st dest ID ctr of token */ 
#define   EXC_NAK     0x08    /* excessive nak - set if 128 naks have occurred */
#define   TOKEN       0x10    /* token has been sighted */    
#define   RCVACT      0x20    /* data transitions detected on the RXIN pin of device */
#define   DUPID       0x40    /* set if a duplicate node ID is detected */
#define   MYRECON     0x80    /* set when lost token timer times out */

/* write command register */
#define   CLR_TX_INT  0x00    /* used in command chaining operation */
#define   OFFSET      0x20    /* 256 byte offset to specified page */
#define   CLR_RI      0x08    /* clear rx int - used in command chaining op */
#define   DISABLETX   0x01    /* Disable Transmitter */

/* cancel any pending tx command, will set TA to 1 when com20020 next receives the token */
#define   DISABLERX   0x02    /* Disable Receiver. */

/* Cancel any pending rx command.  RI set to 1 the next time the token is received */
#define   ENABLETX    0x03    /* Enable Transmitter */
#define   ENABLERX    0x04    /* Enable Receiver */
#define   BROADCAST   0x80    /* Accept Broadcasts */
#define   SHORTPACKET 0x05    /* Accept Short Packets Only */
#define   LONGPACKET  0x0D    /* Accept Long Packet and Short Packets */
#define   CLEARRECON  0x16    /* Resets the RECON Status Bit */
#define   CLEARPOR    0x0E    /* Resets the POR Status Bit */
#define   CLEARFLAGS  0x1E    /* Resets the POR and RECON Status Bits */

/* read/write address pointer high register 2 */
#define   AUTOINC     0x40    /* 1 (autoinc adr ptr), 1 (no autoinc) */
#define   RDDATA      0x80    /* 0 (next access is a write), 1 (read) */
#define   WRDATA      0x7f    /* 0 (next access is a write), 1 (read) */

/* read/write configuration register 6
   sub address bits 0 & 1 (determines the significance of register 7 */
#define   SUBADR_MASK 0x03
#define   TENT_ID_REG 0x00    /* used to build a node network map */
#define   NODE_ID_REG 0x01    /* set or read ID */
#define   SETUP_REG   0x02    /* set mem access and network clock speed */
#define   NEXT_ID_REG 0x03    /* this is the node we are passing token to */
#define   SUB_AD      0xfc    /* template to preserve all but bits 0  1 */

/* meaning of extended timeout bits 3 & 4 */
#define   ET_MASK     0x18    /* mask to isolate bits 4,3 */
#define   US1130      0x00    /* fastest response, idle and recon times */
#define   US563       0x08
#define   US285       0x10
#define   US78        0x18    /* slowest "" */

#define   BACKPLANE   0x04    /* set to access backplane directly */
#define   TXEN        0x20    /* set to enable device to join network */
#define   CCHEN       0x40    /* set to enable command chaining */
#define   RESET       0x80    /* set to exec software reset */

/* read/write tentid, nodeid, setup register 7 */
#define   SLOW_ARB    0x01    /* set for slow mem access - default = 0 */

/* clock prescaler values */
#define   CLK_MASK    0x06    /* mask to isolate clock prescaler bits 1 & 2 */
#define   CLK2500     0x00    /* fastest (2500 Kbps) network speed */
#define   CLK1250     0x02    
#define   CLK625      0x04
#define   CLK312      0x06    /* slowest (312 Kbps) network speed */

#define   TA          0x01    /* Transmitter Available */
#define   TMA         0x02    /* Transmitted Message Acknowledged */
#define   RECON       0x04    /* Reconfiguration Flag */
#define   TEST        0x08    /* Test Flag */
#define   POR         0x10    /* Poer On Reset Indication */
#define   ETS1        0x20    /* Extended Timeout Status 1 */
#define   ETS2        0x40    /* Extended Timeout Status 2 */
#define   RI          0x80    /* Receiever Inhibited */
#define   TA2         0x20    /* TA if chaining */
#define   RI2         0x40    /* RI if chaining */

#define   TRUE        1
#define   FALSE       0

#define   E_OK                0       /* operation successful */
#define   E_BAD_STATUS        1       /* bad initialization status */
#define   E_NOT_INITED        3       /* arcnet was never initialized */
#define   E_BAD_COMMAND       4       /* invalid command value */
#define   E_BAD_PARAMETER     5       /* invalid parameter value */
#define   E_BAD_DATA          6       /* invalid data value */
#define   E_NO_PACKET         7       /* no packet available */
#define   E_NO_TOKEN          8       /* no token seen */
#define   E_BAD_PACKET_SIZE   9       /* bad packet size for packet type */
#define   E_TX_BUSY          10       /* transmitter busy */
#define   E_ACK              11       /* write acked */
#define   E_ABORT            12       /* write aborted */
#define   E_DUPID            13       /* dupicate ID - initialization aborted */
#define   E_ONE_NODE         14       /* only one node on the network */
#define   E_NODE_USED        15       /* node address is used or net full */

/* arcware commands */
#define   SETUP              0
#define   INIT               1
#define   READ               2
#define   WRITE              3
#define   STATUS             4
#define   EXIT               5

#define   MAX_COMMAND_NUMBER 5

/* arcware parameters */
#define   NODEID             0
#define   ACCEPTBROADCAST    1
#define   INBUFS             2
#define   OUTBUFS            3
#define   ACCEPTLONG         4
#define   BACKPLANEMODE      5
#define   SPEED              6
#define   TIMEOUT            7
#define   CHAINING           8
#define   IOPORT_LSB        10
#define   IOPORT_MSB        11
#define   INTLEVEL          12
#define   NOWAIT            13
#define   NOCHECK           14

#define   MAX_PARAMETER_NUMBER 14

//#define   DELAY(x)    {for (j=0; j<x; j++) for (i=0; i<255; i++);}